package com.boful.common.codec.utils;

import java.security.MessageDigest;

import org.apache.commons.codec.binary.Base64;

public class PasswordCodec {

	/***
	 * 密码加密
	 * 
	 * @param msg
	 * @return
	 */
	public static String encode(String msg) {
		try {
			MessageDigest md = MessageDigest.getInstance("SHA");
			md.update(msg.getBytes("UTF-8"));
			byte[] buffer = md.digest();
			String base = Base64.encodeBase64String(buffer);
			return base;
		} catch (Exception e) {
			return null;
		}
	}
}
